package com.reider.log4AS3.dataholder
{
	/**
	 * This class represents a logging level like DEBUG or INFO
	 */
	
	public class Level
	{
		
		private var _priority:int
		private var _name:String
		
		/**
	 	* The priority of the level
	 	*/
		
		public function get priority():int
		{
			return _priority
		}
		
		/**
		 * The name of the level
		 */
		
		public function get name():String
		{
			return _name
		}
		
		/**
		 * Creates a new Level instance
		 * 
		 * @param priority The priority number of the Level
		 * @param name The name of the Level
		 */
		
		public function Level(priority:int, name:String)
		{
			_priority = priority
			_name = name
		}
		
		public function check(operator:String, level:Level):Boolean
		{
			switch(operator)
			{
				case "==":
					return priority == level.priority;
				case ">":
					return priority > level.priority;
				case ">=":
					return priority >= level.priority;
				case "<":
					return priority < level.priority;
				case "<=":
					return priority <= level.priority;
				case "!=":
					return priority != level.priority;
				default:
					throw new ArgumentError("Unknown operator: "+operator)
			}
		}

	}
}